package com.yxinsur.imc.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;
import java.util.List;

import com.yxinsur.imc.business.form.PrerenewalDetailForm;
import com.yxinsur.imc.business.vo.PrerenewalDetailVo;
import com.yxinsur.imc.common.utils.DateUtils;
import com.yxinsur.imc.common.utils.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yxinsur.imc.business.mapper.ImcPrerenewalDetailMapper;
import com.yxinsur.imc.business.domain.ImcPrerenewalDetail;
import com.yxinsur.imc.business.service.IImcPrerenewalDetailService;

/**
 * 待导入续期详情Service业务层处理
 * 
 * @author imc
 * @date 2021-05-26
 */
@Service
public class ImcPrerenewalDetailServiceImpl extends ServiceImpl<ImcPrerenewalDetailMapper, ImcPrerenewalDetail> implements IImcPrerenewalDetailService
{
    private static final Logger logger = LoggerFactory.getLogger(ImcPrerenewalDetailServiceImpl.class);

    @Autowired
    private ImcPrerenewalDetailMapper imcPrerenewalDetailMapper;

    /**
     * 查询待导入续期详情列表
     * 
     * @param prerenewalDetailForm 條件
     * @return 待导入续期详情
     */
    @Override
    public List<PrerenewalDetailVo> selectImcPrerenewalDetailList(PrerenewalDetailForm prerenewalDetailForm)
    {
        return imcPrerenewalDetailMapper.selectImcPrerenewalDetailList(prerenewalDetailForm);
    }

    /**
     * 批量删除续期详情
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteImcPrerenewalDetailByIds(Long[] ids) {
        logger.info("批量删除续期详情操作：{}",ids);
        int count = 0;
        Date date = DateUtils.getNowDate();
        for(Long id:ids){
            ImcPrerenewalDetail detail = this.imcPrerenewalDetailMapper.selectById(id);
            detail.setIsDeleted(detail.getId().toString());
            detail.setUpdateId(SecurityUtils.getUsername());
            detail.setUpdateTime(date);
            count += this.imcPrerenewalDetailMapper.updateById(detail);
        }
        return count;
    }
}
